﻿using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json.Linq;
using System;

namespace LD.Tool
{
    public partial class ToolFTPFrm : FrmToolBase
    {
        public ToolFTPFrm()
        {
            InitializeComponent();
            this.btn_ok.Click += Btn_ok_Click;
            this.Shown += FrmTaskTool_Shown;
        }

        private void FrmTaskTool_Shown(object sender, EventArgs e)
        {
            Init();
        }

        private void Btn_ok_Click(object sender, EventArgs e)
        {
            JObject obj = new JObject(); ;
            obj.Add("ip", this.txt_ftpIp.Text);
            obj.Add("name", this.txt_ftpName.Text);
            obj.Add("pwd", this.txt_ftpPwd.Text);
            this.TB_Tool.Param = obj.ToString();
            this.Close();
        }
        private void Init()
        {
            if (this.TB_Tool.Param == null)
                return;
            JObject obj = JObject.Parse(this.TB_Tool.Param);

            this.txt_ftpIp.Text = obj["ip"].ToString();
            this.txt_ftpName.Text = obj["name"].ToString();
            this.txt_ftpPwd.Text = obj["pwd"].ToString();
        }
    }
}
